package com.chengtong.shop.ctrl.front;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chengtong.shop.service.front.ProductDetailService;

@Controller
@Repository(value="frontProductDetailCtrls")
@RequestMapping(value="product/productDetail")
public class ProductDetailCtrls
{
	@Autowired
	private ProductDetailService productDetailService;
	
	@RequestMapping(value="/{productId}",method=RequestMethod.GET)
	public String init(@PathVariable("productId") String productId, HttpServletRequest request)
	{
		request.setAttribute("productId", productId);
		request.setAttribute("productMap", this.productDetailService.getProductDetailMsg(productId));
		return "front/product/productDetail";
	}
	
	@RequestMapping(value="loadData/{productId}",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> loadData(@PathVariable("productId") String productId)
	{
		Map<String, Object> map = this.productDetailService.getProductDetailMsg(productId);
		return map;
	}
}
